<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
</head>

<body>
    <div id="app">
        <!-- 插值渲染 -->
        <div>{{msg}}</div>
        <!-- 执行一次性插值 -->
        <div v-once>{{msg}}</div>
        <!-- v-html解析代码片段 -->
        <div v-html="url">{{url}}</div>
        <!-- v-bind指令 绑定变量 -->
        <div v-bind:title="title">测试div</div>
        <!-- 绑定变量简写 -->
        <div :title="title">测试div1</div>
        <div>{{count}}</div>
        <!-- 绑定事件v-on：事件类型 -->
        <button v-on:click="toAdd">点我count++</button>
        <!-- 绑定事件简写@ -->
        <button @click="toDel">点我count--</button>
        <!-- js表达式 -->
        <div>{{String(0)}}</div>
        <div>{{Number(msg)}}</div>
        <div>{{count+5}}</div>
        <div>{{msg.split('')}}</div>
    </div>
    <script>
        let vm = new Vue({
            // 将vue对象和dom模板绑定
            el: "#app",
            data: {
                msg: '我是数据模型属性',
                url: "<a href='https://www.baidu.com'>百度一下</a>",
                title: '我是鼠标悬浮才会显示的标题',
                count: 0
            },
            methods: {
                // 自增
                toAdd(){
                    this.count++
                },
                //自减
                toDel(){
                    this.count--
                }
            },
        });
        setTimeout(() => {
            vm.msg = 'hello world'
        }, 3000)
    </script>
</body>

</html>